#!/bin/bash

if [ $# -lt 1 ]; then
    echo Not enough argument!
    exit
fi

for host in hadoop100 hadoop101 hadoop102; do
    echo ================== $host =======================

    for file in $@; do
        if [ -e $file ]; then
            pdir=$(cd -P $(dirname $file); pwd)
            fname=$(basename $file)
            ssh $host "mkdir -p $pdir"
            rsync -av $pdir/$fname $host:$pdir
        else
            echo $file does not exist!
        fi
    done
done
